using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using bitzhuwei.Compiler;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node parameter_declaration in the grammar(AnsiC).
    /// </summary>
    internal partial class Vnparameter_declaration : IFullFormatter {
        // [148]=parameter_declaration : declaration_specifiers declarator ;
        // [149]=parameter_declaration : declaration_specifiers abstract_declarator ;
        // [150]=parameter_declaration : declaration_specifiers ;

        private readonly TokenRange _scope;
        private readonly Vndeclaration_specifiers r1;
        private readonly IFullFormatter? r0;

        public TokenRange Scope => _scope;

        public void Format(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }

        public void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(this.r1, preConfig, writer);
            if (r0 != null) {
                var config = new BlankConfig();
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
        }

        public IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }

        // [148]=parameter_declaration : declaration_specifiers declarator ;
        // dumped by DefaultExtractor
        internal Vnparameter_declaration(Vndeclaration_specifiers r1, Vndeclarator r0) {
            this.r1 = r1;
            this.r0 = r0;
            this._scope = new TokenRange(r1, r0);
        }
        // [149]=parameter_declaration : declaration_specifiers abstract_declarator ;
        // dumped by DefaultExtractor
        internal Vnparameter_declaration(Vndeclaration_specifiers r1, Vnabstract_declarator r0) {
            this.r1 = r1;
            this.r0 = r0;
            this._scope = new TokenRange(r1, r0);
        }
        // [150]=parameter_declaration : declaration_specifiers ;
        // dumped by DefaultExtractor
        internal Vnparameter_declaration(Vndeclaration_specifiers r0) {
            this.r1 = r0;
            this._scope = new TokenRange(r0);
        }

    }
}
